package ${filePackageName};

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 初始化启动执行
 * @author ${projectAuthor}
 * @version 1.0
 * @date ${nowDate}
 */
@Component
@EnableScheduling
public class InitialTask {

    @PostConstruct
    public void init(){
        // 初始化执行的代码
    }

    //延迟1秒后执行第一次，之后每隔10秒执行一次
    @Async("executor1")
    @Scheduled(initialDelay = 1000, fixedDelay = 10000)
    public void task1(){

    }

    //延迟10秒后执行
    @Async("executor2")
    @Scheduled(initialDelay = 10000, fixedRate = Long.MAX_VALUE)
    public void task2(){

    }
}
